﻿@page "/"
@namespace BlazorProject.Pages
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <title>BlazorProject</title>
    <base href="~/" />
    <environment include="Development">
        <link href="~/layui/css/layui.css" rel="stylesheet" />
        <link rel="stylesheet" href="~/layuiadmin/style/admin.css" media="all">
        <link href="~/lib/viewerjs/css/viewer.min.css" rel="stylesheet" />
        <link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
    </environment>
    <environment exclude="Development">
        <link href="~/layui/css/layui.css" rel="stylesheet" />
        <link rel="stylesheet" href="~/layuiadmin/style/admin.css" media="all">
        <link href="~/lib/viewerjs/css/viewer.min.css" rel="stylesheet" />
        <link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
    </environment>
</head>
<body class="layui-layout-body">
    <app>
        <component type="typeof(App)" render-mode="ServerPrerendered" />
    </app>
    <environment include="Development">
        <script src="~/layui/layui.js"></script>
        <script src="~/js/jquery-1.10.2.min.js"></script>
        <script src="~/lib/viewerjs/js/viewer.min.js"></script>
        <script src="_framework/blazor.server.js"></script>
    </environment>
    <environment exclude="Development">
        <script src="~/layui/layui.js"></script>
        <script src="~/js/jquery-1.10.2.min.js"></script>
        <script src="~/lib/viewerjs/js/viewer.min.js"></script>
        <script src="_framework/blazor.server.js"></script>
    </environment>
</body>
</html>
<script type="text/javascript">
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'element'], function () {
        var $ = layui.$;
        var element = layui.element;

        element.on('tab(layadmin-layout-tabs)', function (elem) {
            console.log(elem);
            var src = $(this).attr('lay-id');
            $(this).attr("layadmin-event", "refresh");
        });

        $("#logout").click(function () {
            layer.confirm('确认退出吗？', {
                btn: ['确定', '关闭'], //按钮
                title: '提示'
            }, function () {
                var loadingFlag;
                $.ajax({
                    url: "/Account/Logout",
                    type: "POST",
                    beforeSend: function () {
                        //注意，layer.msg默认3秒自动关闭，如果数据加载耗时比较长，需要设置time
                        loadingFlag = layer.msg('正在处理，请稍候……', { icon: 16, shade: 0.01, shadeClose: false, time: 10000 });
                    },
                    success: function (response) {
                        layer.close(loadingFlag);
                        if (response.success) {
                            //提交 Ajax 成功后，静态更新表格中的数据
                            layer.msg(response.msg, { icon: 1, time: 1500 }, function () {
                                window.location.href = response.url;
                            });
                        } else {
                            layer.msg(response.msg, { icon: 2, time: 1500 });
                        }
                    }
                });
            });
        });

    });
</script>